package com.navjagpal.notes;

import android.app.Application;

import androidx.gdata.documents.DocumentsServer;
import androidx.gdata.documents.DocumentsServerFactory;
import androidx.gdata.spreadsheets.SpreadsheetsServer;
import androidx.gdata.spreadsheets.SpreadsheetsServerFactory;

public class NotesApplication extends Application {

  private String mSpreadsheetsAuth;
  private String mUsername;
  private static NotesApplication mSingleton;
  private SpreadsheetsServer mSpreadsheetsServer;
  private DocumentsServer mDocumentsServer;
  private String mDocumentsAuth;
  
  @Override
  public final void onCreate() {
    super.onCreate();
    mSingleton = this;
  }
  
  public void reset() {
    mSpreadsheetsAuth = null;
    mDocumentsAuth = null;
    mUsername = null;
    mSpreadsheetsServer = null;
    mDocumentsServer = null;
  }
  
  public static NotesApplication getInstance() {
    return mSingleton;
  }
  
  public String getSpreadsheetsAuth() {
    return mSpreadsheetsAuth;
  }
  
  public void setSpreadsheetsAuth(String username, String auth) {
    mUsername = username;
    mSpreadsheetsAuth = auth;
    mSpreadsheetsServer = SpreadsheetsServerFactory.getServer(username, auth);
  }
  
  public void setDocumentsAuth(String username, String auth) {
    mUsername = username;
    mDocumentsAuth = auth;
    mDocumentsServer = DocumentsServerFactory.getServer(username, auth);
  }
  
  public String GetUsername() {
    return mUsername;
  }
  
  public SpreadsheetsServer getSpreadsheetsServer() {
    return mSpreadsheetsServer;
  }
  
  public DocumentsServer getDocumentsServer() {
    return mDocumentsServer;
  }
}
